package ar.com.contable.ganancias.listener;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

import ar.com.contable.ganancias.editor.View;
import ar.com.contable.ganancias.modelVO.CategoryVO;
import ar.com.contable.ganancias.modelVO.ItemVO;
import ar.com.contable.ganancias.modelVO.RowVO;
import ar.com.contable.ganancias.modelVO.YearModelVO;

public class FoldersContentProvider implements ITreeContentProvider{
      /**
	 * 
	 */
	private View AddressContentProvider;

	/**
	 * @param view
	 */
	public FoldersContentProvider(View view) {
		AddressContentProvider = view;
	}

	//@todo
	public Object[] getChildren(Object parentElement){
		 return ((RowVO) parentElement).getChildren(parentElement);
		 
//         if (parentElement instanceof List)
//            return ((List<?>) parentElement).toArray();
//         if (parentElement instanceof PersonFolderVO)
//        	 return ((PersonFolderVO) parentElement).getCategories().toArray();
//         if (parentElement instanceof CategoryVO)
//            return ((CategoryVO) parentElement).getRows().toArray();
         //return new Object[0];
      }
 
      public Object getParent(Object element){
    	  return ((RowVO) element).getParent(element);
//    	  
//         if (element instanceof CategoryVO)
//            return ((CategoryVO) element).getParent();
//         if (element instanceof ItemVO)
//            return ((ItemVO) element).getParent();
//         return null;
      }
 
//@todo      
      public boolean hasChildren(Object element){
    	  
 		return ((RowVO) element).hasChildren(element);
//         if (element instanceof List)
//            return ((List<?>) element).size() > 0;
//         if (element instanceof PersonFolderVO)
//            return ((PersonFolderVO) element).getCategories().size() > 0;
//         if (element instanceof CategoryVO)
//            return ((CategoryVO) element).getRows().size() > 0;
      }
 
      public Object[] getElements(Object folder){
         // cities ist das, was oben in setInput(..) gesetzt wurde.
         return getChildren(folder);
      }
 
      public void dispose(){
      }
 
      public void inputChanged(Viewer viewer, Object oldInput, Object newInput){
    	  //((YearModelVO)viewer.getInput()).refresh();
      }
   }